home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / srcuc.zip / TRAP.H < prev    next >
C/C++ Source or Header  |  1989-09-20  |  5KB  |  129 lines

  1. /* -*-C-*-
  2.  
  3. Copyright (c) 1987, 1988, 1989 Massachusetts Institute of Technology
  4.  
  5. This material was developed by the Scheme project at the Massachusetts
  6. Institute of Technology, Department of Electrical Engineering and
  7. Computer Science.  Permission to copy this software, to redistribute
  8. it, and to use it for any purpose is granted, subject to the following
  9. restrictions and understandings.
  10.  
  11. 1. Any copy made of this software must include this copyright notice
  12. in full.
  13.  
  14. 2. Users of this software agree to make their best efforts (a) to
  15. return to the MIT Scheme project any improvements or extensions that
  16. they make, so that these may be included in future releases; and (b)
  17. to inform MIT of noteworthy uses of this software.
  18.  
  19. 3. All materials developed as a consequence of the use of this
  20. software shall duly acknowledge such use, in accordance with the usual
  21. standards of acknowledging credit in academic research.
  22.  
  23. 4. MIT has made no warrantee or representation that the operation of
  24. this software will be error-free, and MIT is under no obligation to
  25. provide any services, by way of maintenance, update, or otherwise.
  26.  
  27. 5. In conjunction with products arising from the use of this material,
  28. there shall be no use of the name of the Massachusetts Institute of
  29. Technology nor of any adaptation thereof in any advertising,
  30. promotional, or sales literature without prior written consent from
  31. MIT in each case. */
  32.  
  33. /* $Header: trap.h,v 9.42 89/09/20 23:12:11 GMT cph Exp $ */
  34.  
  35. /* Kinds of traps:
  36.  
  37.    Note that for every trap there is a dangerous version.
  38.    The danger bit is the bottom bit of the trap number,
  39.    thus all dangerous traps are odd and viceversa.
  40.  
  41.    For efficiency, some traps are immediate, while some are
  42.    pointer objects.  The type code is multiplexed, and the
  43.    garbage collector handles it specially.
  44.  */
  45.  
  46. /* The following are immediate traps: */
  47.  
  48. #define TRAP_UNASSIGNED                0
  49. #define TRAP_UNASSIGNED_DANGEROUS        1
  50. #define TRAP_UNBOUND                2
  51. #define TRAP_UNBOUND_DANGEROUS            3
  52. #define TRAP_ILLEGAL                4
  53. #define TRAP_ILLEGAL_DANGEROUS            5
  54. #define TRAP_EXPENSIVE                6
  55. #define TRAP_EXPENSIVE_DANGEROUS        7
  56.  
  57. /* TRAP_MAX_IMMEDIATE is defined in const.h */
  58.  
  59. /* The following are not: */
  60.  
  61. #define TRAP_NOP                10
  62. #define TRAP_DANGEROUS                11
  63. #define TRAP_FLUID                12
  64. #define TRAP_FLUID_DANGEROUS            13
  65. #define TRAP_COMPILER_CACHED            14
  66. #define TRAP_COMPILER_CACHED_DANGEROUS        15
  67.  
  68. /* These MUST be distinct */
  69.  
  70. #define TRAP_EXTENSION_TYPE            TC_QUAD
  71. #define TRAP_REFERENCES_TYPE            TC_HUNK3
  72.  
  73. /* Trap utilities */
  74.  
  75. #define get_trap_kind(variable, what)                    \
  76. {                                    \
  77.   variable = OBJECT_DATUM (what);                    \
  78.   if (variable > TRAP_MAX_IMMEDIATE)                    \
  79.     variable = OBJECT_DATUM (MEMORY_REF (what, TRAP_TAG));        \
  80. }
  81.  
  82. /* Common constants */
  83.  
  84. #ifdef b32                /* 32 bit objects */
  85.  
  86. #if (TYPE_CODE_LENGTH == 8)
  87. #define UNASSIGNED_OBJECT        0x32000000
  88. #define DANGEROUS_UNASSIGNED_OBJECT    0x32000001
  89. #define UNBOUND_OBJECT            0x32000002
  90. #define DANGEROUS_UNBOUND_OBJECT    0x32000003
  91. #define ILLEGAL_OBJECT            0x32000004
  92. #define DANGEROUS_ILLEGAL_OBJECT    0x32000005
  93. #define EXPENSIVE_OBJECT        0x32000006
  94. #define DANGEROUS_EXPENSIVE_OBJECT    0x32000007
  95. #endif /* (TYPE_CODE_LENGTH == 8) */
  96.  
  97. #if (TYPE_CODE_LENGTH == 6)
  98. #define UNASSIGNED_OBJECT        0xc8000000
  99. #define DANGEROUS_UNASSIGNED_OBJECT    0xc8000001
  100. #define UNBOUND_OBJECT            0xc8000002
  101. #define DANGEROUS_UNBOUND_OBJECT    0xc8000003
  102. #define ILLEGAL_OBJECT            0xc8000004
  103. #define DANGEROUS_ILLEGAL_OBJECT    0xc8000005
  104. #define EXPENSIVE_OBJECT        0xc8000006
  105. #define DANGEROUS_EXPENSIVE_OBJECT    0xc8000007
  106. #endif /* (TYPE_CODE_LENGTH == 6) */
  107.  
  108. #if (TC_REFERENCE_TRAP != 0x32)
  109. #include "error: trap.h and types.h are inconsistent"
  110. #endif
  111.  
  112. #endif /* b32 */
  113.  
  114. #ifndef UNASSIGNED_OBJECT        /* Safe version */
  115. #define UNASSIGNED_OBJECT        MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_UNASSIGNED)
  116. #define DANGEROUS_UNASSIGNED_OBJECT    MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_UNASSIGNED_DANGEROUS)
  117. #define UNBOUND_OBJECT            MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_UNBOUND)
  118. #define DANGEROUS_UNBOUND_OBJECT    MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_UNBOUND_DANGEROUS)
  119. #define ILLEGAL_OBJECT            MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_ILLEGAL)
  120. #define DANGEROUS_ILLEGAL_OBJECT    MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_ILLEGAL_DANGEROUS)
  121. #define EXPENSIVE_OBJECT        MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_EXPENSIVE)
  122. #define DANGEROUS_EXPENSIVE_OBJECT    MAKE_OBJECT (TC_REFERENCE_TRAP, TRAP_EXPENSIVE_DANGEROUS)
  123. #endif /* UNASSIGNED_OBJECT */
  124.  
  125. #define NOP_OBJECT (LONG_TO_UNSIGNED_FIXNUM (TRAP_NOP))
  126. #define DANGEROUS_OBJECT (LONG_TO_UNSIGNED_FIXNUM (TRAP_DANGEROUS))
  127. #define REQUEST_RECACHE_OBJECT DANGEROUS_ILLEGAL_OBJECT
  128. #define EXPENSIVE_ASSIGNMENT_OBJECT EXPENSIVE_OBJECT
  129.